<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once( DIRNAME(__FILE__).DS.'helper.php' );

$row = get_query();

$isbn  = $row->isbn;


echo '<span class = "book_title">' . $row->title . '</span><br />';
?>


<?php
// This removes HTML comments and HTML tags
$description = strip_html_tags( $row->introdescription );
$words = explode( ' ', $description );
$chars = strlen( $description );
$check = false;

if( $chars > 400 ):?>
<script language = "Javascript">

// Mootools 1.11 code -- Replace with 1.2 code when Joomla upgrades its engine
	window.addEvent( 'domready', function() {
		var check = true;
		var vert = new Fx.Slide( 'vertical_slide' );
		vert.hide();
		$('more_description').addEvent('click', function(e){
			e = new Event(e);
			vert.toggle();
			e.stop();
			if( check )
			{
				$('ellipsis').setHTML('');
				$('more_description').setHTML('{ - }');
				check = false;
			}
			else
			{
				$('ellipsis').setHTML(' ...' );
				$('more_description').setHTML('{ + }');
				check = true;
			}
		});
	});
	
// Mootools 1.2 code
//		window.addEvent( 'domready', function() {
//										var status = {
//											'true': '{ + }',
//											'false': '{ - }'
//										};
//										var ellipsis = {
//											'true': ' ...',
//											'false': ''
//										};
//		
//			var myVerticalSlide = new Fx.Slide( 'vertical_slide' );
//			myVerticalSlide.hide();
//			
//				$( 'more_description' ).addEvent( 'click', function(e){
//									
//									e.stop(); 
//									myVerticalSlide.toggle();
//									$('more_description').set('html', status[myVerticalSlide.open]);
//									$('ellipsis').set('html', ellipsis[myVerticalSlide.open]);
//									
//										
//
//				});
//		});
										
	</script>
<?php
	// Assign the first 54 words to an array and the rest of the words to a second array
	$check = true;
	$startMore = trim( implode( ' ', array_slice( $words, 0, 54 ) ) );
	$endMore = trim( implode( ' ', array_slice ( $words, 54, sizeof( $words ) - 1 ) ) );
endif; ?>

<?php 
	// Get first letter for DROP CAP
	// Take out the first letter from its previous variable
	if( $check )
	{
		$first_letter = trim( substr( strip_tags( $startMore ), 0, 1 ) );
		$startMore = substr( $startMore, 1, strlen( $startMore ) -1  );
	}
	else
	{
		$first_letter = trim( substr( strip_tags( $description ), 0, 1 ) );
		$description = substr( $description, 1, strlen( $description ) - 1 );
	}
?>
<p id = "description" class = "description"><?php if( !$check ) echo '<span class= "drop_cap">' . $first_letter .
	'</span>' . $description . '</p><br />'; else echo '<span class = "drop_cap">' . $first_letter . '</span>' . 
	$startMore .'<span id = "ellipsis"> ...</span>'; ?>

<?php if( $check ): ?>
<span id = "vertical_slide">
	<?php echo $endMore; ?>
</span>
</p>

<a id = "more_description" href = "#" name = "more_description">{ + }</a> 
<?php endif; ?>

<p class = "author"><?php echo $row->author; ?></p>

<?php 
echo '<br />';

?>